<?php

namespace App\Services;

use Illuminate\Support\Facades\DB;
use common\utils\RSACrypt;

class AgentProfileService
{
    public static function info($id)
    {
        $profile = (array)DB::table('agent as u')->leftJoin('agent_property as p', 'u.id', '=', 'p.agent_id')
            ->select([
                'u.agent_name',
                'p.nickname',
                'p.avatar_url',
                'p.birth',
                'p.sex',
                'u.email',
                'p.region_id',
                'p.mobile',
                'p.address',
                'p.nationality',
                'p.postcode',
                'p.qq',
                'p.wechat',
                'p.skype',
            ])->where(['u.id' => $id])->first();
        $profile = RSACrypt::rsaPatch($profile);
        return $profile;
    }
}
